#pragma once

#include <memory>

namespace qb {

    class ProcessMessage
	{
	public:
        ProcessMessage(char* buff, int len, bool needRelease=true, short retCode = 0) 
            : m_buff(buff), m_len(len), m_needRelease(needRelease),m_retCode(retCode) {}
        ~ProcessMessage() {
            if (m_needRelease && m_buff) {
                delete []m_buff;
                m_buff = nullptr;
            }
            m_len = 0;
        }

        const char* getBuff() { return (const char*)m_buff; }
        int getLen() { return m_len; }
        short retCode() const { return m_retCode; }
    private:
        char* m_buff;
        int m_len;
        bool m_needRelease;
        short m_retCode = 0;
	};
}

typedef std::shared_ptr<qb::ProcessMessage> MESSAGE_SHARED_PTR;

